package com.zis;

import com.zis.core.SnowflakeIdWorker;

import java.io.*;

/**
 * Create by wangshen 2017/12/27
 */
public class ImportRegion {

    public static void main(String[] args) {

        try {
            String pathname = "/Users/wangshen/Desktop/2017陕西省行政区划代码";
            File filename = new File(pathname); // 要读取以上路径的input。txt文件
            InputStreamReader reader = null; // 建立一个输入流对象reader
            reader = new InputStreamReader(
                    new FileInputStream(filename));
            BufferedReader br = new BufferedReader(reader); // 建立一个对象，它把文件内容转成计算机能读懂的语言
            String line = "";
            line = br.readLine();
            SnowflakeIdWorker sId = new SnowflakeIdWorker(2,2);
            while (line != null) {
                line = br.readLine(); // 一次读入一行数据
                if (line != null) {
                    // System.out.println(line);
                    String[] areas = line.split(" ");
                    String id = sId.nextId()+"";
                    String sql = "INSERT INTO `a_auct_region` (`REGION_ID`, `REGION_CODE`, `REGION_NAME`, `PARENT_ID`, `REGION_LEVEL`, `REGION_ORDER`) " +
                            "VALUES ('"+id+"', '"+areas[0]+"', '"+areas[2]+"', '"+areas[3]+"', 0, 0);";
                    System.out.println(sql);
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
